package br.ufrj.dcc.comp2.musica.listeners;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import br.ufrj.dcc.comp2.musica.controle.Musica;
import br.ufrj.dcc.comp2.musica.modelo.Turma;
import br.ufrj.dcc.comp2.musica.vista.PainelMenuProfessor;


 public class ListenerMenuProfessor implements ActionListener{


		private Component fonte;
		private PainelMenuProfessor painelMenuProfessor;
		private Musica controle;
		
		public ListenerMenuProfessor(PainelMenuProfessor painel){
			painelMenuProfessor = painel;
			controle = Musica.getInstancia();
		}

		public void actionPerformed(ActionEvent evento) {
			fonte = (Component) evento.getSource();
			if (fonte == painelMenuProfessor.getBotaoGerenciarTurmas()){
				painelMenuProfessor.getControleCardLayout().getPainelGerenciarNotas().getPainelSuperior().getComboSelecionaTurma().removeAllItems();
				for (Turma t : Musica.getInstancia().getMapas().getMapaTurmas().values()) {
					painelMenuProfessor.getControleCardLayout().getPainelGerenciarNotas().getPainelSuperior().getComboSelecionaTurma().addItem(t);
				}
				
				painelMenuProfessor.getControleCardLayout().setCard("Gerenciar Turmas");
			}
			else if(fonte == painelMenuProfessor.getBotaoDadosPessoais()){
				painelMenuProfessor.getControleCardLayout().setCard("Dados Pessoais");
				
			}
			else if(fonte == painelMenuProfessor.getBotaoEmitirRelatorios()){
				painelMenuProfessor.getControleCardLayout().setCard("Relatorios");
			}
			painelMenuProfessor.getControleCardLayout().setUltimoPainel("Menu");
		}
}




